import 'package:flutter/material.dart';
import '../components/my_editable_text.dart' as MyEdit;

import 'key_dict.dart';
import 'key_item.dart';

class MyKeyBoard extends StatelessWidget {
  final Function tap;
  final Function delete;
  final MyEdit.TextEditingController controller;
  final Widget bottomSlot;
  MyKeyBoard({Key key, this.tap, this.delete, this.controller, this.bottomSlot})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AnimatedContainer(
      duration: Duration(microseconds: 500),
      height: 245,
      padding: EdgeInsets.symmetric(vertical: 4, horizontal: 6),
      child: Column(
        children: [
          ...keyDict.map((List it) {
            return Column(
              children: <Widget>[
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: it.map((item) {
                    return Row(
                      children: <Widget>[
                        KeyItem(
                          tap: () {
                            this.tap(item);
                          },
                          delete: () {
                            this.delete();
                          },
                          text: item,
                          currentList: it,
                        ),
                      ],
                    );
                  }).toList(),
                ),
              ],
            );
          }).toList(),
          bottomSlot != null ? bottomSlot : SizedBox()
        ],
      ),
    );
  }
}
